#include "ErrorCode.h"


std::string  firmwareErrorDesc[] {
    "NO_ERROR"
    ,"OPEN_SERIAL_FAILED"
    ,"LOOP_COUNT_NO_MATCH"
    ,"LOOP_SWITCH_FAILED"
    ,"CHANNEL_COMM_ERROR"
    ,"DOOR_ALERTOR_ERROR"
    ,"AC_SWITCH_DETECTOR_ERROR"
    ,"NETWORK_SIGNAL_ERROR"
    ,"JSON_BUILD_ERROR"
    ,"VIDEO_PLAY_ERROR"
    ,"HTTP_HEADER_ERROR"
    ,"UPDATE_FIRMWARE_ERROR"
    ,"UPDATE_PASSWORD_ERROR"
    ,"UPLOAD_OFFLINE_SYSTEM_INFO_ERROR"
    ,"DEVICE_MODULE_OFFLINE_ERROR"
    ,"IOTGATWAY_COMMAND_ERROR"
    ,"NET_INTERFACE_CONFIGURE_ERROR"
};



FirmwareCategory firmwareCategory;


std::string& buildErrorMessage(const int returnCode, const int errCode, std::string& prefix) {
    std::string::size_type prefixSize = prefix.size();
    prefix.resize(prefixSize + STRING_BUFFER_SIZE);

    prefixSize += snprintf(&prefix[prefixSize], STRING_BUFFER_SIZE + 1, ":returnCode[%d],errno[%d],%s", returnCode, errCode, strerror(errno));

    prefix.resize(prefixSize);

    return prefix;
}
